﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;

namespace 反向工程;

public partial class NetTestContext : DbContext
{
    public NetTestContext()
    {
    }

    public NetTestContext(DbContextOptions<NetTestContext> options)
        : base(options)
    {
    }

    public virtual DbSet<TBooks2> TBooks2s { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263.
        => optionsBuilder.UseSqlServer("Server=.;Database=NetTest;Trusted_Connection=True;TrustServerCertificate=True;MultipleActiveResultSets=true");

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<TBooks2>(entity =>
        {
            entity.ToTable("T_Books2");

            entity.HasIndex(e => e.AuthorName, "IX_T_Books2_AuthorName").IsUnique();

            entity.HasIndex(e => e.Price, "IX_T_Books2_Price");

            entity.Property(e => e.AuthorName).HasMaxLength(40);
            entity.Property(e => e.Price).HasDefaultValue(88.900000000000006);
        });

        OnModelCreatingPartial(modelBuilder);
    }

    partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
